import json
import app


# 封装通用的 断言函数
def common_assert(test_case, resp, status_code, success, code, message):
    test_case.assertEqual(status_code, resp.status_code)
    test_case.assertEqual(success, resp.json().get('success'))
    test_case.assertEqual(code, resp.json().get('code'))
    test_case.assertIn(message, resp.json().get('message'))


# 封装函数，读取json文件
def read_json_data(filename):
    with open(filename, mode='r', encoding='utf-8') as f:
        json_data = json.load(f)

        result_list = []
        for login_data in json_data:
            result_list.append(tuple(login_data.values()))

        return result_list


if __name__ == '__main__':
    filename = app.BASE_DIR + '/data/login.json'
    read_json_data(filename)
